// PlanetValue.h
// Keeps track of events that are registered by the player for when the planet
// value passes a certain point.

#ifndef PLANET_VALUE_EVENT_HANDLER_H_
#define PLANET_VALUE_EVENT_HANDLER_H_


struct PlanetEventRegistrationStruct;
typedef std::multimap<int, PlanetEventRegistrationStruct> PlanetValueRegistrationMap;
typedef PlanetValueRegistrationMap::iterator PlanetValueRegistrationIterator;
typedef std::map<std::string, int> EventNamePlanetValueLookup;

class PlanetValueEventHandler
{
protected:
	


	PlanetValueRegistrationMap m_registrationMap;
	EventNamePlanetValueLookup m_lookup;

	void insertNewRegistrationStruct(std::string szRegistrationName, int iPlanetValue, bool bAscending, bool bDescending, bool bRepeat,
		int iTotalCount = 0, int iTotalNewCount = 0);
	PlanetValueRegistrationIterator getIteratorForRegistration(std::string szRegistrationName);


public:
	PlanetValueEventHandler();
	virtual ~PlanetValueEventHandler();

	// Registers an event to recieve notification of when the planet value is hit.
	void registerPlanetEvent(std::string registrationName, int iPlanetValue, bool bAscending, bool bDescending, bool bRepeat);
	
	// Unregisters an event, and also clears all the data for it.
	void unregisterPlanetEvent(std::string registrationName);

	// Removes all registered events.
	void unregisterAllPlanetEvents();

	// Called when the planet value changes.
	void handlePlanetValueChange(int iOld, int iNew);

	// Called by a user to see what the new event count on their event is.
	int getEventNewHitCount(std::string szRegistrationName);

	// Called by a user to change the hit count (basically, to say that they "got it")
	void changeEventNewHitCount(std::string szRegistrationName, int iChange);

	// Called by a user to set the hit count (basically, to say that they "got it")
	void setEventNewHitCount(std::string szRegistrationName, int iValue);

	// Serialization functions
	void read(FDataStreamBase* pStream);
	void write(FDataStreamBase* pStream);

	

};

#endif
